export default {
  state: {
    globalInfo: {
      contentInfo: {
        opacity: '0.9',
        bgcolor: 'rgb(7, 17, 27)'
      }
    },
    personal_tags: [
      { name: '打工仔', value: 6985 },
      { name: '头昏', value: 4611 },
      { name: '网瘾少年', value: 4475 },
      { name: '奋斗ing', value: 1157 },
      { name: '神经病', value: 890 },
      { name: '前端开发', value: 840 },
      { name: '运动衫', value: 757 },
      { name: '90s', value: 754 },
      { name: '阿宅', value: 748 },
      { name: '自由', value: 722 },
      { name: '新鲜空气', value: 668 },
      { name: '空', value: 660 },
      { name: '起床', value: 658 },
    ],
    tech_tags: [
      { name: 'Vue', value: 1164 },
      { name: 'JavaScript', value: 758 },
      { name: 'HTML5/CSS3', value: 711 },
      { name: 'Module', value: 703 },
      { name: 'Rxjs', value: 670 },
      { name: 'Bootstrap', value: 641 },
      { name: 'Jquery', value: 629 },
      { name: 'TypeScript', value: 584 },
    ]
  },
  mutations: {
    updateTagsInfo(state, name) {
      function arraySort() {
        function compare(property) {
          return function(a, b) {
            let val1 = a[property]
            let val2 = b[property]
            return val2 - val1
          }
        }
        state.personal_tags.sort(compare('value'))
        state.tech_tags.sort(compare('value'))
      }
      
      state.personal_tags.some((item, index) => {
        if(item.name === name) {
          item.value ++
          arraySort()
          return true
        }
      })
      state.tech_tags.some((item, index) => {
        if(item.name === name) {
          item.value ++
          arraySort()
          return true
        }
      })
    }
  }
}